#include<iostream>
using namespace std;
int map[101][101]={0};//存原始数据
int r,c;//行数，列数
int dis[101][101]={0};//存储节点的最长路径值
 
int f(int form,int to){
	if(dis[form][to]>0)return dis[form][to];//如果已经记录了值，直接返回
	int left=0,right=0,up=0,down=0;
	if(form+1<=r){//处理上路
		if(map[form+1][to]<map[form][to])up=1+f(form+1,to);
		else up=1;
	}
	else up=1;
	if(form-1>=1){//处理下路
		if(map[form-1][to]<map[form][to])down=1+f(form-1,to);
		else down=1;
	}
	else down=1;
	if(to+1<=c){//处理右路
		if(map[form][to+1]<map[form][to])right=1+f(form,to+1);
		else right=1;
	}
	else right=1;
	if(to-1>=1){//处理左路
		if(map[form][to-1]<map[form][to])left=1+f(form,to-1);
		else left=1;
	}
	else left=1;
	if(left<right)left=right;
	if(left<up)left=up;
	if(left<down)left=down;
	return left;//返回最大值
}
 
int main(){
	int i,j;
	cin>>r>>c;
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++)
			cin>>map[i][j];
	int sum=0;
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++){
			dis[i][j]=f(i,j);//记录每个节点的最长路径
			if(sum<dis[i][j])sum=dis[i][j];//选出最大长度
		}
	cout<<sum<<endl;
	return 0;
}